<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@ taglib uri="http://displaytag.sf.net" prefix="display"%>
<%@ taglib uri="http://www.springframework.org/tags" prefix="s"%>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@ taglib uri="http://www.springframework.org/security/tags" prefix="ss"%>

<jsp:include page="../header.jsp" />
<script>
	$(function() {
		$(document).ready(function() {
			if (!$('#showFind').is(':checked')) {
				$('#find').hide();
			}
		});
	});
	function showHide() {
		$(function() {
			if ($('#showFind').is(':checked')) {
				$('#find').show("slow");
			} else {
				$('#find').hide("slow");
			}
		});
	}
</script>
<div id="content">
	<div id="topstory" class="box">
		<h1>
			<fmt:message key="user.list.title" />
		</h1>
	</div>
	<div class="padding">
		<div id="dialog-confirm" title="Empty the recycle bin?" style="display: none;">
			<p>
				<span class="ui-icon ui-icon-alert" style="float: left; margin: 0 7px 20px 0;"></span>This item will be permanently deleted and cannot be recovered. Are you
				sure?
			</p>
		</div>
		<c:if test="${not empty error3}">
			<tr>
				<td colspan="4">
					<div class="ui-widget">
						<div class="ui-state-error ui-corner-all" style="margin-top: 20px; padding: 0 .7em;">
							<p>
								<span class="ui-icon ui-icon-alert" style="float: left; margin-right: .3em;"></span> <strong>Error !</strong>
								<c:out value="${error3.message }" />
							</p>
						</div>
					</div>
				</td>
			</tr>
		</c:if>
		<div>
			<input type="checkbox" id="showFind" onclick="showHide()">
		</div>
		<div id="find">
			<form:form action="/isLibrary/users/findByLogin.do" commandName="user" method="POST">
				<table border="0" cellspacing="5" cellpadding="0" width="100%" class="formTable tplBorder">
					<thead>
						<tr>
							<td colspan="4"><h3>Find by Login</h3>
							</td>
						</tr>
					</thead>
					<tr>
						<td width="15%"></td>
						<td width="35%"></td>
						<td width="15%"></td>
						<td width="35%"></td>
					</tr>
					<c:if test="${not empty error1}">
						<tr>
							<td colspan="4">
								<div class="ui-widget">
									<div class="ui-state-error ui-corner-all" style="margin-top: 20px; padding: 0 .7em;">
										<p>
											<span class="ui-icon ui-icon-alert" style="float: left; margin-right: .3em;"></span> <strong>Error !</strong>
											<c:out value="${error1.message }" />
										</p>
									</div>
								</div>
							</td>
						</tr>
					</c:if>
					<tr>
						<td class="label"><fmt:message key="user.login" />
						</td>
						<td><form:input path="login" />
						</td>
						<td colspan="2" />
					</tr>
					<tr>
						<td><input type="submit" />
						</td>
						<td colspan="3" />
					</tr>
				</table>
			</form:form>
			<form:form action="/isLibrary/users/findByName.do" commandName="user" method="POST" id="byName">
				<table border="0" cellspacing="5" cellpadding="0" width="100%" class="formTable tplBorder">
					<thead>
						<tr>
							<td colspan="4"><h3>Find by Name</h3>
							</td>
						</tr>
					</thead>
					<tr>
						<td width="15%"></td>
						<td width="35%"></td>
						<td width="15%"></td>
						<td width="35%"></td>
					</tr>
					<c:if test="${not empty error2}">
						<tr>
							<td colspan="4">
								<div class="ui-widget">
									<div class="ui-state-error ui-corner-all" style="margin-top: 20px; padding: 0 .7em;">
										<p>
											<span class="ui-icon ui-icon-alert" style="float: left; margin-right: .3em;"></span> <strong>Error !</strong>
											<c:out value="${error2.message }" />
										</p>
									</div>
								</div>
							</td>
						</tr>
					</c:if>
					<tr>
						<td class="label"><fmt:message key="user.name" />
						</td>
						<td><form:input path="jmeno" />
						</td>
						<td class="label"><fmt:message key="user.surname" />
						</td>
						<td><form:input path="prijmeni" />
						</td>
					</tr>
					<tr>
						<td><input type="submit" />
						</td>
						<td colspan="3" />
					</tr>
				</table>
			</form:form>
			</div>
			<h2></h2>
			<display:table class="formTable tplBorder" export="false" id="data" name="list" requestURI="/users.do"
				decorator="cz.boxdesign.library.web.decorator.UserTableDecorator" pagesize="10">
				<ss:authorize access="hasRole('ROLE_ADMIN')">
					<display:column property="editUrl" titleKey="common.edit" sortable="false" />
					<display:column property="deleteUrl" titleKey="common.delete" sortable="false" />
					<display:column property="prolongUrl" titleKey="user.prolong" sortable="false" />
				</ss:authorize>
				<display:column property="showUrl" titleKey="common.show" sortable="false" />
				<display:column property="login" titleKey="user.login" sortable="true" />
				<display:column property="jmeno" titleKey="user.name" sortable="true" />
				<display:column property="prijmeni" titleKey="user.surname" sortable="true" />
			</display:table>
		</div>
		<!-- /padding -->
	</div>
	<!-- /content -->
	<jsp:include page="side-menu.jsp" />
	<jsp:include page="../foother.jsp" />